package org.shj.basic

object MapTupleDemo {
  def main(args: Array[String]): Unit = {
    
    //创建map几种方式方法
    val datas = Map("Spark" -> 6, "hadoop" -> 11)
    
    val persons = Map(("Jack", 20), ("Joan", 18))
    
    val langs = scala.collection.mutable.Map("Java" -> 23, "Scala" -> 12)
    langs("Scala") = 15
    
    for((name,age) <- langs)
      println("name=" + name + ";age=" + age)
      
    println(langs.getOrElse("python", 13))
    
    val students = new scala.collection.mutable.HashMap[String, Int]
    students += (("liangyongqi", 18), ("zhuyin", 24))
    students += ("yangmi" -> 19)
    students -= ("zhuyin")
    
    for((name,age) <- students)
      println("name=" + name + ";age=" + age)
    
    val sort = scala.collection.immutable.SortedMap(("Java", 13), ("Scala" ,12), ("Hadoop" , 20))
    for((name,age) <- sort)
      println(name + ", " + age)
    
    val tuple = ("I", " am ", 30, "years")
    println(tuple._1)
  }
}